/*
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:syria_sports/core/utils/show_toast.dart';


typedef OnConsentGatheringCompleteListener = void Function(FormError? error);
bool rewardedAdE = true;
late Function _loadRewardedAdLocale;
after60()async{
  await Future.delayed(const Duration(seconds: 10)).then((value) async {
    await _loadRewardedAdLocale.call();
    rewardedAdE = true;
  });
}


/// The Google Mobile Ads SDK provides the User Messaging Platform (Google's IAB
/// Certified consent management platform) as one solution to capture consent for
/// users in GDPR impacted countries. This is an example and you can choose
/// another consent management platform to capture consent.
class ConsentManager {
  /// Helper variable to determine if the app can request ads.
  Future<bool> canRequestAds() async {
    return await ConsentInformation.instance.canRequestAds();
  }

  /// Helper variable to determine if the privacy options form is required.
  Future<bool> isPrivacyOptionsRequired() async {
    return await ConsentInformation.instance
        .getPrivacyOptionsRequirementStatus() ==
        PrivacyOptionsRequirementStatus.required;
  }

  /// Helper method to call the Mobile Ads SDK to request consent information
  /// and load/show a consent form if necessary.
  void gatherConsent(
      OnConsentGatheringCompleteListener onConsentGatheringCompleteListener) {
    // For testing purposes, you can force a DebugGeography of Eea or NotEea.
    ConsentDebugSettings debugSettings = ConsentDebugSettings(
      // debugGeography: DebugGeography.debugGeographyEea,
    );
    ConsentRequestParameters params =
    ConsentRequestParameters(consentDebugSettings: debugSettings);

    // Requesting an update to consent information should be called on every app launch.
    ConsentInformation.instance.requestConsentInfoUpdate(params, () async {
      ConsentForm.loadAndShowConsentFormIfRequired((loadAndShowError) {
        // Consent has been gathered.
        onConsentGatheringCompleteListener(loadAndShowError);
      });
    }, (FormError formError) {
      onConsentGatheringCompleteListener(formError);
    });
  }

  /// Helper method to call the Mobile Ads SDK method to show the privacy options form.
  void showPrivacyOptionsForm(
      OnConsentFormDismissedListener onConsentFormDismissedListener) {
    ConsentForm.showPrivacyOptionsForm(onConsentFormDismissedListener);
  }
}

class AppBarItem {
  static const adInpsectorText = 'Ad Inspector';
  static const privacySettingsText = 'Privacy Settings';

  final String label;
  final int value;

  AppBarItem(this.label, this.value);
}


/// An example app that loads a banner ad.
class BannerExample extends StatefulWidget {
  const BannerExample({super.key});

  @override
  BannerExampleState createState() => BannerExampleState();
}

class BannerExampleState extends State<BannerExample> {
  final _consentManager = ConsentManager();
  var _isMobileAdsInitializeCalled = false;
  BannerAd? _bannerAd;
  bool _isLoadedBanner = false;
  Orientation? _currentOrientation;
  RewardedAd? _rewardedAd;



  String _adUnitIdForRewarded = Platform.isAndroid
      ? 'ca-app-pub-4225804055583308/6149453566'
      : 'ca-app-pub-3940256099942544/1712485313';
  String _adUnitIdBanner = Platform.isAndroid
      ? 'ca-app-pub-4225804055583308/9490782831'
      : 'ca-app-pub-3940256099942544/2435281174';




  @override
  void initState() {
    if(kDebugMode){
      _adUnitIdBanner = "ca-app-pub-3940256099942544/9214589741";
      _adUnitIdForRewarded = "ca-app-pub-3940256099942544/5224354917";
    }
    super.initState();
    _loadRewardedAdLocale = _loadRewardedAd;
    initRewardedAds();
  }

  initRewardedAds(){
    _consentManager.gatherConsent((consentGatheringError) {
      if (consentGatheringError != null) {
        // Consent not obtained in current session.
        debugPrint("${consentGatheringError.errorCode}: ${consentGatheringError.message}");
      }

      // Check if a privacy options entry point is required.
      _getIsPrivacyOptionsRequired();

      // Attempt to initialize the Mobile Ads SDK.
      _initializeMobileAdsSDK();
    });

    // This sample attempts to load ads using consent obtained in the previous session.
    _initializeMobileAdsSDK();
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
            title: const Text('ادعمنا الآن')),
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Center(
              child: ElevatedButton(
                  onPressed: (){
                    if(rewardedAdE==false){
                      showErrorMessage(message: 'يمكنك مشاهدة اعلان واحد كل 60 ثانية');
                      return;
                    }
                    _rewardedAd?.show(onUserEarnedReward:
                        (AdWithoutView ad, RewardItem rewardItem)async {
                      showMessage('شكرا لك على مساهمتك في تطوير المنصة');
                      setState(() {});
                      await after60();
                    });
                    setState(() {
                      rewardedAdE = false;
                    });
                  }, child: const Padding(
                    padding: EdgeInsets.all(8.0),
                    child: Text('ادعمنا عن طريق مشاهدة اعلان بكامل الصفحة',style: TextStyle(color: Colors.white),),
                  )),
            ),
          ],
        ),
        bottomNavigationBar: OrientationBuilder(
          builder: (context, orientation) {
            if (_currentOrientation != orientation) {
              _isLoadedBanner = false;
              _loadAd();
              _currentOrientation = orientation;
            }
            return (_bannerAd != null && _isLoadedBanner)?
              SizedBox(
                width: _bannerAd!.size.width.toDouble(),
                height: _bannerAd!.size.height.toDouble(),
                child: AdWidget(ad: _bannerAd!),
              ):Container();
          },
        ));
  }


  /// Redraw the app bar actions if a privacy options entry point is required.
  void _getIsPrivacyOptionsRequired() async {
    if (await _consentManager.isPrivacyOptionsRequired()) {}
  }

  /// Initialize the Mobile Ads SDK if the SDK has gathered consent aligned with
  /// the app's configured messages.
  void _initializeMobileAdsSDK() async {
    if (_isMobileAdsInitializeCalled) {
      return;
    }

    if (await _consentManager.canRequestAds()) {
      _isMobileAdsInitializeCalled = true;

      // Initialize the Mobile Ads SDK.
      MobileAds.instance.initialize();

      // Load an ad.
      _loadAd();
      _loadRewardedAd();
    }
  }
  /// Loads and shows a banner ad.
  ///
  /// Dimensions of the ad are determined by the width of the screen.
  void _loadAd() async {
    // Only load an ad if the Mobile Ads SDK has gathered consent aligned with
    // the app's configured messages.
    var canRequestAds = await _consentManager.canRequestAds();
    if (!canRequestAds) {
      return;
    }

    if (!mounted) {
      return;
    }

    // Get an AnchoredAdaptiveBannerAdSize before loading the ad.
    final size = await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
        MediaQuery.sizeOf(context).width.truncate());

    if (size == null) {
      // Unable to get width of anchored banner.
      return;
    }

    BannerAd(
      adUnitId: _adUnitIdBanner,
      request: const AdRequest(),
      size: size,
      listener: BannerAdListener(
        // Called when an ad is successfully received.
        onAdLoaded: (ad) {
          setState(() {
            _bannerAd = ad as BannerAd;
            _isLoadedBanner = true;
          });
        },
        // Called when an ad request failed.
        onAdFailedToLoad: (ad, err) {
          ad.dispose();
        },
        // Called when an ad opens an overlay that covers the screen.
        onAdOpened: (Ad ad) {},
        // Called when an ad removes an overlay that covers the screen.
        onAdClosed: (Ad ad) {},
        // Called when an impression occurs on the ad.
        onAdImpression: (Ad ad) {},
      ),
    ).load();
  }
  /// Loads a rewarded ad.
  void _loadRewardedAd() async {
    // Only load an ad if the Mobile Ads SDK has gathered consent aligned with
    // the app's configured messages.
    var canRequestAds = await _consentManager.canRequestAds();
    if (!canRequestAds) {
      showErrorMessage(message: 'لا يمكنك مشاهدة الاعلان الان الرجاء المحاولة لاحقاً');
      return;
    }
    RewardedAd.load(
        adUnitId: _adUnitIdForRewarded,
        request: const AdRequest(),
        rewardedAdLoadCallback: RewardedAdLoadCallback(onAdLoaded: (ad) {
          ad.fullScreenContentCallback = FullScreenContentCallback(
            // Called when the ad showed the full screen content.
              onAdShowedFullScreenContent: (ad) {},
              // Called when an impression occurs on the ad.
              onAdImpression: (ad) {},
              // Called when the ad failed to show full screen content.
              onAdFailedToShowFullScreenContent: (ad, err) {
                ad.dispose();
              },
              // Called when the ad dismissed full screen content.
              onAdDismissedFullScreenContent: (ad) {
                ad.dispose();
              },
              // Called when a click is recorded for an ad.
              onAdClicked: (ad) {});

          // Keep a reference to the ad so you can show it later.
          _rewardedAd = ad;
        }, onAdFailedToLoad: (LoadAdError error) {
          // ignore: avoid_print
          print('RewardedAd failed to load: $error');
        }));
  }


  @override
  void dispose() {
    _bannerAd?.dispose();
    _rewardedAd?.dispose();
    super.dispose();
  }
}

*/
